<template>
  <div class="p-20px">
    <el-card>
      <el-alert :title="`共 ${total} 条记录`" type="info" show-icon :closable="false" />

      <el-table v-loading="isLoading" :data="list" style="width: 100%;" class="mt-10px mb-15px">
        <el-table-column type="index" width="50" />
        <el-table-column prop="type" label="操作类型" />
        <el-table-column prop="author" label="操作人" />
        <el-table-column prop="title" label="执行结果" />
        <el-table-column prop="display_time" label="操作时间" />
        <el-table-column prop="forecast" label="描述" />
      </el-table>

      <el-row type="flex" justify="end">
        <el-pagination
          background
          layout="prev, pager, next, sizes, jumper"
          :total="total"
          v-model:current-page="query.page"
          v-model:page-size="query.pagesize"
          :page-sizes="[10, 20, 30, 40]"
        />
      </el-row>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { reactive, watch } from 'vue'
import { getLogList } from '@/api/logs'

const isLoading = ref(false)
const total = ref(0)
const list = ref([])
const query = reactive({
  page: 1,
  pagesize: 10
})

function onSearch() {
  isLoading.value = true
  getLogList(query)
    .then(data => {
      console.log('data: ', data)
      isLoading.value = false
    })
    .catch(() => {
      // ElMessage.error(e.message || '获取列表失败')
      isLoading.value = false
    })
}

onSearch()

watch([() => query.page, () => query.pagesize], onSearch)
</script>
